package com.wzdigit.wms.raw.controller.common;

import com.wzdigit.framework.RandomlyThrowsException;
import com.wzdigit.framework.exception.RestStatusException;
import com.wzdigit.framework.model.response.ErrorEntity;
import com.wzdigit.wms.basic.GoodsIsHoldEnum;
import com.wzdigit.wms.basic.enums.*;
import com.wzdigit.wms.basic.enums.inv.HoldDtlGoodsStatusEnum;
import com.wzdigit.wms.basic.enums.inv.HoldDtlStatusEnum;
import com.wzdigit.wms.basic.enums.inv.HoldHeaderStatusEnum;
import com.wzdigit.wms.basic.enums.inv.HoldHeaderTypeEnum;
import com.wzdigit.wms.basic.enums.inv.HoldHeaderWayEnum;
import com.wzdigit.wms.basic.enums.raw.RawAsnDtlStatusEnum;
import com.wzdigit.wms.basic.enums.raw.RawAsnHeaderStatusEnum;
import com.wzdigit.wms.basic.util.enums.SystemModuleEnum;

import io.swagger.annotations.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.wzdigit.wms.raw.constant.RawWareConstant;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@Api(tags = "公共枚举控制层")
@RequestMapping(value = RawWareConstant.API_VERSION)
public class CommonEnumController {
	
    public static final String REQUSET_MODEL = "/sys/common/enum";

    @RandomlyThrowsException
    @ApiOperation(value = "获取收货通知单状态枚举", notes = "获取收货通知单状态枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getAsnHeaderEnum")
    public List<Map<String, Object>> getAsnHeaderEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return RawAsnHeaderStatusEnum.getEnumListByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    
    @RandomlyThrowsException
    @ApiOperation(value = "获取收货通知单明细状态枚举", notes = "获取收货通知单明细状态枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getAsnDtlEnum")
    public List<Map<String, Object>> getAsnDtlEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return RawAsnDtlStatusEnum.getEnumListByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "获取收货通知单明细货品清单状态枚举", notes = "获取收货通知单明细货品清单状态枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getAsnDtlGoodsStatusEnum")
    public List<Map<String, Object>> getAsnDtlGoodsStatusEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return AsnDtlGoodsStatusEnum.getEnumListByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "获取采购订单状态枚举", notes = "获取采购订单状态枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getPoHeaderEnum")
    public List<Map<String, Object>> getPoHeaderEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return PoHeaderStatusEnum.getEnumListByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "获取采购订单明细状态枚举", notes = "获取采购订单明细状态枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getPoDtlEnum")
    public List<Map<String, Object>> getPoDtlEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return PoDtlStatusEnum.getEnumListByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "获取库存【冻结/解冻】单据类型枚举", notes = "获取库存【冻结/解冻】单据类型枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getHoldHeaderTypeEnum")
    public List<Map<String, Object>> getHoldHeaderTypeEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return HoldHeaderTypeEnum.getEnumListByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "获取库存【冻结/解冻】单据状态枚举", notes = "获取库存【冻结/解冻】单据状态枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getHoldHeaderStatusEnum")
    public List<Map<String, Object>> getHoldHeaderStatusEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return HoldHeaderStatusEnum.getEnumListByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "获取【冻结/解冻】方式枚举", notes = "获取【冻结/解冻】方式枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getHoldHeaderWayEnum")
    public List<Map<String, Object>> getHoldHeaderWayEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return HoldHeaderWayEnum.getEnumListByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "获取库存【冻结/解冻】单明细状态枚举", notes = "获取库存【冻结/解冻】单明细状态枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getHoldDtlStatusEnum")
    public List<Map<String, Object>> getHoldDtlStatusEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return HoldDtlStatusEnum.getEnumListByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "获取库存【冻结/解冻】单明细货品清单状态枚举", notes = "获取库存【冻结/解冻】单明细货品清单状态枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getHoldDtlGoodsStatusEnum")
    public List<Map<String, Object>> getHoldDtlGoodsStatusEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return HoldDtlGoodsStatusEnum.getEnumListByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "获取条码状态枚举", notes = "获取条码状态枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getGoodsStatusEnum")
    public List<Map<String, Object>> getGoodsStatusEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return GoodsStatusEnum.getEnumListByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "获取条码是否冻结枚举", notes = "获取条码是否冻结枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getGoodsIsHoldEnum")
    public List<Map<String, Object>> getGoodsIsHoldEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return GoodsIsHoldEnum.getEnumListByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "获取品质状态枚举", notes = "获取品质状态枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getQaStatusEnum")
    public List<Map<String, Object>> getQaStatusEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return QaStatusEnum.getEnumListByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "获取库存性质枚举", notes = "获取库存性质枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getInvAttrEnum")
    public List<Map<String, Object>> getInvAttrEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return InvAttrEnum.getEnumListByDescription();
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }
    
    @RandomlyThrowsException
    @ApiOperation(value = "获取原材料入库单据类型枚举", notes = "获取原材料入库单据类型枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getAsnTypeEnum")
    public List<Map<String, Object>> getAsnTypeEnum(
            HttpServletRequest servletRequest, 
            HttpServletResponse servletResponse) {
        try {
            return AsnTypeEnum.getEnumListBySystemModule(SystemModuleEnum.RAW);
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }


    @RandomlyThrowsException
    @ApiOperation(value = "获取原材料出库单据类型枚举", notes = "获取原材料入库单据类型枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getGdnTypeEnum")
    public List<Map<String, Object>> getGdnTypeEnum(
            HttpServletRequest servletRequest,
            HttpServletResponse servletResponse) {
        try {
            return GdnTypeEnum.getEnumListBySystemModule(SystemModuleEnum.RAW);
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }


    @RandomlyThrowsException
    @ApiOperation(value = "获取原材料各种单据类型枚举", notes = "获取原材料各种单据类型枚举")
    @ApiResponses({@ApiResponse(code = 500, message = "系统异常", response = ErrorEntity.class)})
    @GetMapping(value = REQUSET_MODEL + "/getAllRawEnum")
    public List<Map<String, Object>> getAllRawEnum(
            HttpServletRequest servletRequest,
            HttpServletResponse servletResponse) {
        try {
            List<Map<String, Object>> list1 = GdnTypeEnum.getEnumListBySystemModule(SystemModuleEnum.RAW);
            List<Map<String, Object>> list2 = AsnTypeEnum.getEnumListBySystemModule(SystemModuleEnum.RAW);
            List<Map<String, Object>> list3 = TransferTypeEnum.getEnumListByDescription("RawTransferType");
            list1.addAll(list2);
            list1.addAll(list3);
            return list1;
        } catch (RestStatusException ex) {
            servletResponse.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            throw ex;
        }
    }



}
